package practice;

public class Husband {
    private String name;
    private int age;
    private Wife wife;

    public Husband(String name, int age, Wife wife) {
        this.name = name;
        this.age = age;
        this.wife = wife;
    }

    public Husband(String name, int age) {
        this(name, age, null);
    }

    public void setWife(Wife wife) {
        this.wife = wife;
    }

    @Override
    public String toString() {
        return "姓名：" + name + "\t年龄：" + age;
    }

    public void getInfo() {
        System.out.print(this);
        if (wife != null)
            System.out.print("\n妻子：\n" + wife);
        System.out.println("\n");
    }
}
